package com.binguo.api.form;

import com.binguo.common.exception.ServiceException;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;

import static com.binguo.common.exception.ErrorCode.PHONE_INVITE_CODE_BOTH_EMPTY;

/**
 * Created by haibang on 18/5/9.
 */
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Data
public class InitForm {

    @ApiParam(value = "手机号", required = true)
    private String phone;

    @ApiParam(value = "邀请码", required = true)
    private String inviteCode;


    @ApiParam(value = "设备号", required = true)
    @NotNull
    private String deviceId;

    @ApiParam(value = "所属门店", required = true)
    @NotNull
    private String shopName;

    @ApiParam(value = "收银台名字", required = true)
    @NotNull
    private String cashierDeskName;

    public void validate(){
        if(phone == null && inviteCode == null) throw new ServiceException(PHONE_INVITE_CODE_BOTH_EMPTY);

    }

}
